package com.punai.assetlibrary.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.punai.assetlibrary.entiry.dtos.SrQdZckDto;
import com.punai.assetlibrary.service.SrQdZckService;
import com.punai.common.utils.PageUtils;
import com.punai.common.utils.StringUtil;
import com.punai.config.domain.ConfigInventoryChapter;
import com.punai.config.domain.ConfigInventoryLib;
import com.punai.config.mapper.ConfigInventoryChapterMapper;
import com.punai.config.mapper.ConfigInventoryLibMapper;
import com.punai.dataclean.domain.IncomeDataCleanInfo;
import com.punai.evaluationSystem.incomeDataEvalute.domain.EvaluationDataPriceSr;
import com.punai.evaluationSystem.incomeDataEvalute.domain.EvaluationResultsSr;
import com.punai.evaluationSystem.incomeDataEvalute.domain.EvaluationSrInfo;
import com.punai.evaluationSystem.incomeDataEvalute.mapper.EvaluationDataPriceSrMapper;
import com.punai.evaluationSystem.incomeDataEvalute.mapper.EvaluationResultsSrMapper;
import com.punai.evaluationSystem.incomeDataEvalute.mapper.EvaluationSrInfoMapper;
import com.punai.externalccb.domain.EcoCbfeeitem;
import com.punai.prodatalibrary.domain.LibProjectInfo;
import com.punai.prodatalibrary.mapper.LibProjectInfoMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
public class SrQdZckServiceImpl implements SrQdZckService {

    @Autowired
    private EvaluationDataPriceSrMapper evaluationDataPriceSrMapper;

    @Autowired
    private ConfigInventoryLibMapper configInventoryLibMapper;

    @Autowired
    private EvaluationResultsSrMapper evaluationResultsSrMapper;

    @Autowired
    private EvaluationSrInfoMapper evaluationSrInfoMapper;

    @Autowired
    private LibProjectInfoMapper libProjectInfoMapper;

    @Autowired
    private ConfigInventoryChapterMapper configInventoryChapterMapper;


    @Override
    public List<EvaluationDataPriceSr> initTableData(SrQdZckDto zckDto) {
        String tabName = zckDto.getTabName();
        List<EvaluationDataPriceSr> page = null;
        String ptype = zckDto.getPtype();
        if ("2".equals(ptype)) {
            switch (tabName) {
                case "fb_0":
                    List<String> chapterIds = new ArrayList<>();
                    chapterIds.add(zckDto.getCategoryId());
                    List<ConfigInventoryChapter> children = configInventoryChapterMapper.selectChildById(zckDto.getCategoryId(), Long.valueOf(zckDto.getParamCompId()));
                    if (CollUtil.isNotEmpty(children)) {
                        for (ConfigInventoryChapter child : children) {
                            chapterIds.add(child.getId());
                        }
                    }

                    List<ConfigInventoryLib> all = configInventoryLibMapper.selectConfigInventoryLibList(new ConfigInventoryLib() {{
                        setCompanyId(Long.valueOf(zckDto.getParamCompId()));
                        setListNorm(zckDto.getInventoryStandard());
                        setType(zckDto.getIncentoryType());
                    }}, chapterIds);

                    Set<String> codes = all.stream().map(ConfigInventoryLib::getListCoding).collect(Collectors.toSet());
                    if (codes.size() == 0) return page;
                    Map<String, Object> bean = BeanUtil.beanToMap(zckDto);
                    bean.put("codes", codes);
                    page = getEvaluationDataPriceSrs(bean);
                    return page;
                case "dj_1":
                case "zj_2":
                    zckDto.setCategoryId("");
                    Map<String, Object> beanToMap = BeanUtil.beanToMap(zckDto);
                    beanToMap.put("isWhatEvaluate", "02");
                    return getEvaluationDataPriceSrs(beanToMap);
            }
        } else if ("3".equals(ptype)) {
            Map<String, Object> beanToMap = BeanUtil.beanToMap(zckDto);
            beanToMap.put("isWhatEvaluate", "03");
            page = evaluationDataPriceSrMapper.findAllResultsByMap(beanToMap);
            return page;
        } else if ("7".equals(ptype)) {
            Map<String, Object> beanToMap = BeanUtil.beanToMap(zckDto);
            beanToMap.put("isWhatEvaluate", "03");
            page = evaluationDataPriceSrMapper.findAllResultsByMapInto(beanToMap);
            return page;
        } else if ("4".equals(ptype)) {
            switch (tabName) {
                case "fb_0":
                    String listCode = zckDto.getListCode();
                    List<String> codes = new ArrayList<>();
                    if (StringUtils.isNotEmpty(listCode)) {
                        codes.add(listCode);
                    } else {
                        List<String> chapterIds = new ArrayList<>();
                        chapterIds.add(zckDto.getCategoryId());
                        List<ConfigInventoryChapter> children = configInventoryChapterMapper.selectChildById(zckDto.getCategoryId(), Long.valueOf(zckDto.getParamCompId()));
                        if (CollUtil.isNotEmpty(children)) {
                            for (ConfigInventoryChapter child : children) {
                                chapterIds.add(child.getId());
                            }
                        }
                        List<ConfigInventoryLib> all = configInventoryLibMapper.selectConfigInventoryLibList(new ConfigInventoryLib() {{
                            setCompanyId(Long.valueOf(zckDto.getParamCompId()));
                            setListNorm(zckDto.getInventoryStandard());
                            setType(zckDto.getIncentoryType());
                        }}, chapterIds);
                        codes = all.stream().map(ConfigInventoryLib::getListCoding).collect(Collectors.toList());
                    }

                    Map<String, Object> beanToMap = BeanUtil.beanToMap(zckDto);
                    beanToMap.put("isWhatEvaluate", "02");
                    beanToMap.put("codes", codes);
                    page = getEvaluationDataPriceSrs(beanToMap);
                    return page;
                case "dj_1":
                case "zj_2":
                    Map<String, Object> beanToMap1 = BeanUtil.beanToMap(zckDto);
                    beanToMap1.put("isWhatEvaluate", "02");
                    return evaluationDataPriceSrMapper.findAllResultsByMapInto(beanToMap1);
            }
        } else if ("5".equals(ptype)) {
            switch (tabName) {
                case "fb_0":
                    String listCode = zckDto.getListCode();
                    List<String> codes = new ArrayList<>();
                    zckDto.setEvalType("01");
                    if (StringUtil.isNotEmpty(listCode)) {
                        codes.add(listCode);
                    }
                    Map<String, Object> beanToMap = BeanUtil.beanToMap(zckDto);
                    beanToMap.put("codes", codes);
                    page = getEvaluationDataPriceSrs(beanToMap);
                    return page;
                case "dj_1":
                case "zj_2":
                    Map<String, Object> bean = BeanUtil.beanToMap(zckDto);
                    bean.put("isWhatEvaluate", "01");
                    PageUtils.startPage();
                    page = evaluationDataPriceSrMapper.findAllResultsByMapInto(bean);
                    return page;
            }
        } else {
            switch (tabName) {
                case "fb_0":
                    List<String> chapterIds = new ArrayList<>();
                    chapterIds.add(zckDto.getCategoryId());
                    List<ConfigInventoryChapter> children = configInventoryChapterMapper.selectChildById(zckDto.getCategoryId(), Long.valueOf(zckDto.getParamCompId()));
                    if (CollUtil.isNotEmpty(children)) {
                        for (ConfigInventoryChapter child : children) {
                            chapterIds.add(child.getId());
                        }
                    }

                    List<ConfigInventoryLib> all = configInventoryLibMapper.selectConfigInventoryLibList(new ConfigInventoryLib() {{
                        setCompanyId(Long.valueOf(zckDto.getParamCompId()));
                        setListNorm(zckDto.getInventoryStandard());
                        setType(zckDto.getIncentoryType());
                    }}, chapterIds);

                    Set<String> codes = all.stream().map(ConfigInventoryLib::getListCoding).collect(Collectors.toSet());
                    if (codes.size() == 0) return page;
                    Map<String, Object> searchMap = new HashMap<>();
                    searchMap.put("codes", codes);
                    searchMap.put("flag", "1");
                    searchMap.put("isWhatEvaluate", "01");
                    searchMap.put("treeType", tabName);
                    searchMap.put("timeStart", zckDto.getTimeStart());
                    searchMap.put("timeEnd", zckDto.getTimeEnd());
                    searchMap.put("region", zckDto.getAddress());
                    page = getEvaluationDataPriceSrs(searchMap);
                    return page;
                case "dj_1":
                case "zj_2":
                    Map<String, Object> beanToMap = BeanUtil.beanToMap(zckDto);
                    beanToMap.put("isWhatEvaluate", "01");
                    return getEvaluationDataPriceSrs(beanToMap);
            }
        }
        return null;
    }

    private List<EvaluationDataPriceSr> getEvaluationDataPriceSrs(Map<String, Object> beanToMap) {
        PageUtils.startPage();
        return evaluationDataPriceSrMapper.findAllResultsByMap(beanToMap);
    }


    @Override
    public List<EvaluationDataPriceSr> getImageData(Map<String, Object> beanToMap) {
        beanToMap.put("flag", "1");
        String ptype = (String) beanToMap.get("ptype");
        List<EvaluationDataPriceSr> allBySqlQuery = null;
        if ("1".equals(ptype)) {
            beanToMap.put("isWhatEvaluate", "01");
            allBySqlQuery = evaluationDataPriceSrMapper.findAllResultsBySearchImage(beanToMap);
        } else if ("3".equals(ptype)) {
            beanToMap.put("isWhatEvaluate", "03");
            allBySqlQuery = evaluationDataPriceSrMapper.findAllResultsBySearchImage(beanToMap);
        } else {
            beanToMap.put("isWhatEvaluate", "02");
            allBySqlQuery = evaluationDataPriceSrMapper.findAllResultsBySearchImage(beanToMap);
        }
        return allBySqlQuery;
    }


    @Override
    public List<IncomeDataCleanInfo> calcZHDJ(Map<String, List<EvaluationDataPriceSr>> collect, List<EvaluationDataPriceSr> imageData) {
        List<IncomeDataCleanInfo> infoList = new ArrayList<>();
        Map<String, List<EvaluationDataPriceSr>> listMap = imageData.stream().collect(Collectors.groupingBy(EvaluationDataPriceSr::getId, Collectors.toList()));

        for (Map.Entry<String, List<EvaluationDataPriceSr>> stringListEntry : collect.entrySet()) {
            List<EvaluationDataPriceSr> value = stringListEntry.getValue();
            List<String> ids = value.stream().map(EvaluationDataPriceSr::getId).collect(Collectors.toList());
            List<EvaluationSrInfo> evaluateInfoList = evaluationSrInfoMapper.selectList(Wrappers.<EvaluationSrInfo>
                    lambdaQuery().in(EvaluationSrInfo::getPid, ids));
            if (CollUtil.isNotEmpty(evaluateInfoList)) {
                for (EvaluationSrInfo evaluateInfo : evaluateInfoList) {
                    IncomeDataCleanInfo info = new IncomeDataCleanInfo();
                    LibProjectInfo basicInfo = libProjectInfoMapper.selectOne(Wrappers.<LibProjectInfo>lambdaQuery()
                            .eq(LibProjectInfo::getProId, evaluateInfo.getProid()));
                    info.setPjjgsj(stringListEntry.getKey());
                    String province = basicInfo.getProvince();
                    String city = basicInfo.getCity();
                    String region = basicInfo.getRegion();
                    String constructionUnitarea = province + city + region;
                    info.setAddress(constructionUnitarea);
                    info.setCompany(basicInfo.getProjectDept() == null ? "" : basicInfo.getProjectDept());
                    List<EvaluationDataPriceSr> priceSrs = listMap.get(evaluateInfo.getPid());
                    if (CollUtil.isNotEmpty(value)) info.setPrice(priceSrs.get(0).getUserPrice());
                    infoList.add(info);
                }
            }
        }

        return infoList;

    }


    @Override
    public List<IncomeDataCleanInfo> calcLRE(Map<String, List<EvaluationDataPriceSr>> listMap) {
        List<IncomeDataCleanInfo> result = new ArrayList<>();
        for (Map.Entry<String, List<EvaluationDataPriceSr>> entry : listMap.entrySet()) {
            List<String> ids = entry.getValue().stream().map(EvaluationDataPriceSr::getId).collect(Collectors.toList());
            List<EvaluationSrInfo> evaluateInfoList = evaluationSrInfoMapper.selectList(Wrappers.<EvaluationSrInfo>
                    lambdaQuery().in(EvaluationSrInfo::getPid, ids));
            for (EvaluationSrInfo evaluateInfo : evaluateInfoList) {
                IncomeDataCleanInfo info = new IncomeDataCleanInfo();
                String linkDataJson = evaluateInfo.getLinkDataJson();
                List<EcoCbfeeitem> cbFeeItems = JSON.parseArray(linkDataJson, EcoCbfeeitem.class);
                if (CollUtil.isNotEmpty(cbFeeItems)) {
                    BigDecimal srj = cbFeeItems.stream().filter(v -> v.getYsprice() != null).map(EcoCbfeeitem::getYsprice).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal cbj = cbFeeItems.stream().filter(v -> v.getTargettaxprice() != null).map(EcoCbfeeitem::getTargettaxprice).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal lre = srj.subtract(cbj).setScale(3, BigDecimal.ROUND_HALF_UP);
                    info.setLre(lre);
                }
                info.setPjjgsj(entry.getKey());
                LibProjectInfo basicInfo = libProjectInfoMapper.selectOne(Wrappers.<LibProjectInfo>lambdaQuery()
                        .eq(LibProjectInfo::getProId, evaluateInfo.getProid()));
                info.setCompany(basicInfo.getProjectDept());//公司
                String province = basicInfo.getProvince();
                String city = basicInfo.getCity();
                String region = basicInfo.getRegion();
                String constructionUnitarea = province + city + region;
                info.setAddress(constructionUnitarea);//地区
                result.add(info);
            }
        }
        return result;
    }


    @Override
    public Set<String> getHeadData(String code, String number) {
        Map<String, Object> map = new HashMap<>();
        List<String> codes = new ArrayList<>();
        codes.add(code);
        map.put("codes", codes);
        map.put("flag", "1");
        map.put("isWhatEvaluate", number);
        List<EvaluationDataPriceSr> allBySqlQuery = evaluationDataPriceSrMapper.findAllResultsBySearchImage(map);

        Set<String> list = Optional.ofNullable(allBySqlQuery)
                .map(List::stream)
                .orElseGet(Stream::empty)
                .map(EvaluationDataPriceSr::getPjjgsj)
                .collect(Collectors.toSet());

        return list;
    }

    @Override
    public Set<String> getHeadDataZHDJ(String code) {
        Map<String, Object> map = new HashMap<>();
        List<String> codes = new ArrayList<>();
        codes.add(code);
        map.put("codes", codes);
        map.put("flag", "1");
        map.put("isWhatEvaluate", "02");
        List<EvaluationDataPriceSr> allBySqlQuery = evaluationDataPriceSrMapper.selectEvaluationDataPriceSrList(null);

        Set<String> list = Optional.ofNullable(allBySqlQuery)
                .map(List::stream)
                .orElseGet(Stream::empty)
                .map(EvaluationDataPriceSr::getPjjgsj)
                .collect(Collectors.toSet());

        return list;
    }


    @Override
    public List<EvaluationSrInfo> findByEvaluateInfo(Map<String, List<EvaluationDataPriceSr>> map) {
        List<EvaluationSrInfo> result = new ArrayList<>();
        if (CollUtil.isNotEmpty(map)) {
            for (Map.Entry<String, List<EvaluationDataPriceSr>> entry : map.entrySet()) {
                List<String> ids = entry.getValue().stream().map(EvaluationDataPriceSr::getId).collect(Collectors.toList());
                List<EvaluationSrInfo> evaluateInfoList = evaluationSrInfoMapper.selectList(Wrappers.<EvaluationSrInfo>lambdaQuery()
                        .in(EvaluationSrInfo::getPid, ids));
                if (CollUtil.isNotEmpty(evaluateInfoList)) {
                    for (EvaluationSrInfo info : evaluateInfoList) {
                        LibProjectInfo basicInfo = libProjectInfoMapper.selectOne(Wrappers.<LibProjectInfo>lambdaQuery()
                                .eq(LibProjectInfo::getProId, info.getProid()));
                        String implementUnit = basicInfo.getProjectDept();
                        String province = basicInfo.getProvince();
                        String city = basicInfo.getCity();
                        String region = basicInfo.getRegion();
                        String constructionUnitarea = province + city + region;
                        info.setCompany(implementUnit);
                        info.setPjjgsj(entry.getKey());
                        info.setAddress(constructionUnitarea);
                        result.add(info);
                    }
                }
            }
        }
        return result;
    }


    public Map<String, Object> findByZbStructItemGS(Map<String, List<EvaluationDataPriceSr>> map, List<EvaluationDataPriceSr> imageData) {
        Map<String, List<EvaluationDataPriceSr>> mapR = imageData.stream().collect(Collectors.groupingBy(EvaluationDataPriceSr::getId, Collectors.toList()));

        List<String> x = new ArrayList<>(map.keySet());
        List<Map<String, Object>> y = new ArrayList<>();

        List<EvaluationSrInfo> result = new ArrayList<>();
        if (CollUtil.isNotEmpty(map)) {
            for (Map.Entry<String, List<EvaluationDataPriceSr>> entry : map.entrySet()) {
                List<EvaluationDataPriceSr> list = entry.getValue();
                for (EvaluationDataPriceSr priceSr : list) {
                    List<EvaluationSrInfo> infoList = evaluationSrInfoMapper.selectList(Wrappers.<EvaluationSrInfo>lambdaQuery().eq(EvaluationSrInfo::getPid, priceSr.getPid()));
                    if (CollUtil.isNotEmpty(infoList)) {
                        for (EvaluationSrInfo info : infoList) {
                            LibProjectInfo basicInfo = libProjectInfoMapper.selectOne(Wrappers.<LibProjectInfo>lambdaQuery().eq(LibProjectInfo::getProId, info.getProid()));
                            String implementUnit = basicInfo.getProjectDept();
                            String province = basicInfo.getProvince();
                            String city = basicInfo.getCity();
                            String region = basicInfo.getRegion();
                            String constructionUnitarea = province + city + region;
                            // TODO 地区
                            info.setCompany(implementUnit);
                            info.setPjjgsj(entry.getKey());
                            info.setAddress(constructionUnitarea);
                            List<EvaluationDataPriceSr> priceSrs = mapR.get(info.getPid());
                            if (CollUtil.isNotEmpty(priceSrs)) {
                                BigDecimal userPrice = priceSrs.get(0).getUserPrice();
                                info.setPriceresult(userPrice);
                            }
                            result.add(info);
                        }
                    }
                }
            }
        }

        Map<String, Object> m = new HashMap<>();
        m.put("x", x);
        m.put("y", y);

        Map<String, List<EvaluationSrInfo>> map1 = result.stream().filter(v -> v.getCompany() != null).collect(Collectors.groupingBy(EvaluationSrInfo::getCompany, Collectors.toList()));

        if (CollUtil.isNotEmpty(result)) {
            for (Map.Entry<String, List<EvaluationSrInfo>> stringListEntry : map1.entrySet()) {
                Map<String, Object> l = new HashMap<>();
                l.put("name", stringListEntry.getKey());
                l.put("type", "line");
                ArrayList<String> d = new ArrayList<>();

                for (String s : x) {
                    Map<String, List<EvaluationSrInfo>> listMap = stringListEntry.getValue().stream().collect(Collectors.groupingBy(EvaluationSrInfo::getPjjgsj, Collectors.toList()));
                    List<EvaluationSrInfo> itemList = listMap.get(s);
                    if (CollUtil.isNotEmpty(itemList)) {
                        String sum = itemList.stream().map(EvaluationSrInfo::getPriceresult).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(3, BigDecimal.ROUND_HALF_UP).toPlainString();
                        d.add(sum);
                    } else {
                        d.add("-");
                    }
                }
                l.put("data", d);
                y.add(l);
            }
        }
        return m;
    }


    @Override
    public Map<String, Object> findByZbStructItemDQ(Map<String, List<EvaluationDataPriceSr>> map, List<EvaluationDataPriceSr> imageData) {
        Map<String, List<EvaluationDataPriceSr>> mapR = imageData.stream().collect(Collectors.groupingBy(EvaluationDataPriceSr::getId, Collectors.toList()));

        List<String> x = new ArrayList<>(map.keySet());
        List<Map<String, Object>> y = new ArrayList<>();

        List<EvaluationSrInfo> result = new ArrayList<>();
        if (CollUtil.isNotEmpty(map)) {
            for (Map.Entry<String, List<EvaluationDataPriceSr>> entry : map.entrySet()) {
                List<EvaluationDataPriceSr> list = entry.getValue();
                for (EvaluationDataPriceSr priceSr : list) {
                    List<EvaluationSrInfo> infoList = evaluationSrInfoMapper.selectList(Wrappers.<EvaluationSrInfo>lambdaQuery().eq(EvaluationSrInfo::getPid, priceSr.getId()));
                    if (CollUtil.isNotEmpty(infoList)) {
                        for (EvaluationSrInfo info : infoList) {
                            LibProjectInfo basicInfo = libProjectInfoMapper.selectOne(Wrappers.<LibProjectInfo>lambdaQuery()
                                    .eq(LibProjectInfo::getProId, info.getProid()));
                            String implementUnit = basicInfo.getProjectDept();
                            String province = basicInfo.getProvince();
                            String city = basicInfo.getCity();
                            String region = basicInfo.getRegion();
                            String constructionUnitarea = province + city + region;
                            info.setCompany(implementUnit);
                            info.setPjjgsj(entry.getKey());
                            info.setAddress(constructionUnitarea);
                            List<EvaluationDataPriceSr> priceSrs = mapR.get(info.getPid());
                            if (CollUtil.isNotEmpty(priceSrs)) {
                                BigDecimal userPrice = priceSrs.get(0).getUserPrice();
                                info.setPriceresult(userPrice);
                            }
                            result.add(info);
                        }
                    }
                }
            }
        }

        Map<String, Object> m = new HashMap<>();
        m.put("x", x);
        m.put("y", y);

        Map<String, List<EvaluationSrInfo>> map1 = result.stream().filter(v -> v.getAddress() != null).collect(Collectors.groupingBy(EvaluationSrInfo::getAddress, Collectors.toList()));

        if (CollUtil.isNotEmpty(result)) {
            for (Map.Entry<String, List<EvaluationSrInfo>> stringListEntry : map1.entrySet()) {
                Map<String, Object> l = new HashMap<>();
                l.put("name", stringListEntry.getKey());
                l.put("type", "line");
                ArrayList<String> d = new ArrayList<>();

                for (String s : x) {
                    Map<String, List<EvaluationSrInfo>> listMap = stringListEntry.getValue().stream().collect(Collectors.groupingBy(EvaluationSrInfo::getPjjgsj, Collectors.toList()));
                    List<EvaluationSrInfo> itemList = listMap.get(s);
                    if (CollUtil.isNotEmpty(itemList)) {
                        String sum = itemList.stream().map(EvaluationSrInfo::getPriceresult).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(3, BigDecimal.ROUND_HALF_UP).toPlainString();
                        d.add(sum);
                    } else {
                        d.add("-");
                    }
                }
                l.put("data", d);
                y.add(l);
            }
        }
        return m;
    }

    @Override
    public Set<String> getHeadDataZB(String code) {
        Map<String, Object> map = new HashMap<>();
        List<String> codes = new ArrayList<>();
        codes.add(code);
        map.put("codes", codes);
        map.put("flag", "1");
        map.put("isWhatEvaluate", "03");
        List<EvaluationDataPriceSr> allBySqlQuery = evaluationDataPriceSrMapper.findAllResultsBySearchImage(map);

        Set<String> list = Optional.ofNullable(allBySqlQuery)
                .map(List::stream)
                .orElseGet(Stream::empty)
                .map(EvaluationDataPriceSr::getPjjgsj)
                .collect(Collectors.toSet());

        return list;
    }


    @Override
    public List<EvaluationSrInfo> findEvaluateInfoByPid(List<EvaluationDataPriceSr> priceSrList) {
        List<String> ids = priceSrList.stream().map(EvaluationDataPriceSr::getId).collect(Collectors.toList());
        List<EvaluationSrInfo> list = evaluationSrInfoMapper.selectList(Wrappers.<EvaluationSrInfo>lambdaQuery().in(EvaluationSrInfo::getPid, ids));
        return list;
    }

    @Override
    public List<EvaluationResultsSr> findAllEvaluateInfo(String type) {
        return evaluationResultsSrMapper.selectList(Wrappers.<EvaluationResultsSr>lambdaQuery().eq(EvaluationResultsSr::getEvaluateType, type));
    }

    @Override
    public List<EvaluationResultsSr> getQc(SrQdZckDto form) {
        return evaluationResultsSrMapper.selectEvaluationByEvId(BeanUtil.beanToMap(form));
    }

    @Override
    public Map<String, Object> findByPriceRangMaxAndMin(EvaluationDataPriceSr priceSr) {
        Map<String, Object> result = evaluationSrInfoMapper.findByPriceRangMaxAndMin(priceSr);
        return result;
    }
}
